

#include "stdafx.h"

#include "../../loader.h"

using namespace dlguif;

 
Loader g_loader;
void*  g_main_form = NULL;

void Marker(LONG x, LONG y, HDC hdc) 
{ 
 

	//hdc = GetDC(hwnd); 
	MoveToEx(hdc, (int) x - 10, (int) y, (LPPOINT) NULL); 
	LineTo(hdc, (int) x + 10, (int) y); 
	MoveToEx(hdc, (int) x, (int) y - 10, (LPPOINT) NULL); 
	LineTo(hdc, (int) x, (int) y + 10); 

	//ReleaseDC(hwnd, hdc); 
}

void DrawARectangle(HDC hdc) 
{
	HPEN hpen, hpenOld;
	HBRUSH hbrush, hbrushOld;
	assert(0);
	/*

	// Create a green pen.
	hpen = CreatePen(PS_SOLID, 10, RGB(0, 255, 0));
	// Create a red brush.
	hbrush = CreateSolidBrush(RGB(255, 0, 0));

	// Select the new pen and brush, and then draw.
	hpenOld = SelectObject(hdc, (HGDIOBJ)hpen);	
	hbrushOld = SelectObject(hdc, (HGDIOBJ)hbrush);
	Rectangle(hdc, 100,100, 200,200);

	// Do not forget to clean up.
	SelectObject(hdc, hpenOld);
	DeleteObject(hpen);
	SelectObject(hdc, hbrushOld);
	DeleteObject(hbrush);

	*/
}

void CALLBACK OnGuiEventCallBack(void* user_context, const callback_info* ci)
{
	 if(ci->eventType == EVENT_TYPE_FORM_CLOSE) g_loader.PostExit(0);
	 if(ci->eventType == EVENT_TYPE_FORM_PAINT)
	 {
		 HDC hdc = g_loader.GetFormDeviceContext(g_main_form);
		 Marker(100, 100, hdc);
		 Ellipse( hdc, 40, 40, 220, 220 );
		 DrawARectangle(hdc);
	 }
}


int _tmain(int argc, _TCHAR* argv[])
{
	g_main_form = g_loader.CreateForm("window", "mainform", 
		&Loader::MakeRectangle(10, 10, 800, 600) );

	g_loader.SetGuiEventCallBack(OnGuiEventCallBack,  NULL );

	g_loader.ShowForm(g_main_form);
 
	while( g_loader.ProcessMessages() )
	{
	 
		Sleep(1);
	}

	return 0;
}
